package com.xbongbong.saas.factory.publicrule;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.saas.enums.ClueRuleEnum;
import com.xbongbong.saas.enums.ClueSeniorRuleTypeEnum;

/**
 * @author long
 * @version v1.0
 * @date 2020/12/1 16:44
 * @since v1.0
 */
public class OperateClueRuleValueFactory {

    public static IOperateClueRuleValue operateRuleValueFactory(Integer ruleType) throws XbbException {

        ClueRuleEnum clueRuleEnum = ClueRuleEnum.getByCode(ruleType);

        switch (clueRuleEnum) {
            case NO_COMMUNICATE_RULE:
                return new OperateNoCommunicateClueRuleValue();
            case MAX_CLUE_NUM_RULE:
                return new OperateMaxClueNumRuleValue();
            case PRE_PRINCIPAL_RULE:
                return new OperatePrePrincipalClueRuleValue();
            case GAIN_RATE_RULE:
                return new OperateGainRateClueRuleValue();
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100028, I18nStringConstant.RULE_TYPE_ERROR);
        }
    }


    public static IOperateClueRuleValue operateSeniorRuleValueFactory(Integer ruleType) throws XbbException {

        ClueSeniorRuleTypeEnum clueSeniorRuleTypeEnum = ClueSeniorRuleTypeEnum.getByCode(ruleType);

        switch (clueSeniorRuleTypeEnum) {
            case MAX_CLUE_NUM_RULE:
                return new OperateMaxClueNumRuleValue();
            case PRE_PRINCIPAL_RULE:
                return new OperatePrePrincipalClueRuleValue();
            case GAIN_RATE_RULE:
                return new  OperateGainRateClueRuleValue();
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100028, I18nStringConstant.RULE_TYPE_ERROR);
        }
    }
}
